@ECHO OFF
ECHO =========================================================
ECHO.
ECHO Compilation started. Project: Excel wrapper
ECHO.
ECHO =========================================================
ECHO.
REM		PTH_NET_2 is an environment variable like %WINDIR%\Microsoft.NET\Framework\v2.0.xxxxx
REM		PTH_RES is an environment variable like C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin
REM		EXC11 must be set to the path where Excel 11 will be found
REM		EXC12 must be set to the path where Excel 12 will be found
REM		SET EXC11="%WINDIR%\assembly\GAC\Microsoft.Office.Interop.Excel\11.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll"
REM		SET EXC12="%WINDIR%\assembly\GAC\Microsoft.Office.Interop.Excel\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll"


REM		LIBPATH must be set to the location of libraries (delimited by a ;)
SET LIBPATH="."
SET LIBPATHR=%LIBPATH%
SET LIBPATHD=%LIBPATH%

REM		Check if the user has provided required variables
IF	"%PTH_NET_2%" == "" GOTO Err_PTH_NET_2
IF	"%PTH_RES%" == "" GOTO Err_PTH_RES
IF NOT EXIST "%PTH_NET_2%\Vbc.exe" GOTO Err_PTH_NET_2
IF NOT EXIST "%PTH_RES%\Resgen.exe" GOTO Err_PTH_RES
GOTO	Basic_Env_Ok

:Err_PTH_NET_2
ECHO	You need to set variable PTH_NET_2 to location where Vbc.exe can be found
GOTO	ErrorHandler

:Err_PTH_RES
ECHO	You need to set variable PTH_RES to location where Resgen.exe can be found
GOTO	ErrorHandler

:Basic_Env_Ok

REM		Enshure that object path exists
IF NOT EXIST "./obj" MD "obj"

IF NOT EXIST "..\build" MD "..\build"
IF NOT EXIST "..\build\XL00" MD "..\build\XL00"
IF NOT EXIST "..\build\XL11" MD "..\build\XL11"
IF NOT EXIST "..\build\XL12" MD "..\build\XL12"
IF NOT EXIST "..\build\XL00\Release" MD "..\build\XL00\Release"
IF NOT EXIST "..\build\XL11\Release" MD "..\build\XL11\Release"
IF NOT EXIST "..\build\XL12\Release" MD "..\build\XL12\Release"
IF NOT EXIST "..\build\XL00\Debug" MD "..\build\XL00\Debug"
IF NOT EXIST "..\build\XL11\Debug" MD "..\build\XL11\Debug"
IF NOT EXIST "..\build\XL12\Debug" MD "..\build\XL12\Debug"


SET OUT00_REL="..\build\XL00\Release\FSK_XL.dll"
SET OUT00_DBG="..\build\XL00\Debug\FSK_XL.dll"
SET OUT11_REL="..\build\XL11\Release\FSK_XL.dll"
SET OUT11_DBG="..\build\XL11\Debug\FSK_XL.dll"
SET OUT12_REL="..\build\XL12\Release\FSK_XL.dll"
SET OUT12_DBG="..\build\XL12\Debug\FSK_XL.dll"

DEL /F /Q "..\build\XL00\Release\*.*"
DEL /F /Q "..\build\XL00\Debug\*.*"
DEL /F /Q "..\build\XL11\Release\*.*"
DEL /F /Q "..\build\XL11\Debug\*.*"
DEL /F /Q "..\build\XL12\Release\*.*"
DEL /F /Q "..\build\XL12\Debug\*.*"

CALL ResLst.bat 
IF NOT %ERRORLEVEL% == 0 GOTO ErrorHandler




REM    >>>>>>>>>>>>>>>>>  00   <<<<<<<<<<<<<<<<<<
ECHO =========================================================
ECHO.
ECHO Empty stub
ECHO.
ECHO =========================================================
%PTH_NET_2%\Vbc.exe  @bldrsp.txt     /define:EMPTY_STUB=True /libpath:%LIBPATHD% /out:%OUT00_DBG% /debug /define:DEBUG=1 
IF NOT %ERRORLEVEL% == 0 GOTO ErrorHandler

%PTH_NET_2%\Vbc.exe  @bldrsp.txt 	 /define:EMPTY_STUB=True /libpath:%LIBPATHR% /out:%OUT00_REL% /optimize
IF NOT %ERRORLEVEL% == 0 GOTO ErrorHandler


REM    >>>>>>>>>>>>>>>>>  11   <<<<<<<<<<<<<<<<<<
ECHO =========================================================
ECHO.
ECHO Excel 11
ECHO.
ECHO =========================================================

IF "%EXC11%" == "" GOTO E_11_Skipped
%PTH_NET_2%\Vbc.exe  @bldrsp.txt     /reference:"%EXC11%" /define:EMPTY_STUB=False /libpath:%LIBPATHD% /out:%OUT11_DBG% /debug /define:DEBUG=1 
IF NOT %ERRORLEVEL% == 0 GOTO ErrorHandler

%PTH_NET_2%\Vbc.exe  @bldrsp.txt 	 /reference:"%EXC11%" /define:EMPTY_STUB=False /libpath:%LIBPATHR% /out:%OUT11_REL% /optimize
IF NOT %ERRORLEVEL% == 0 GOTO ErrorHandler
GOTO E_11_OK

:E_11_Skipped
ECHO	Warning! EXC11 was not found; Excel 11 interface will not be available
:E_11_OK

REM    >>>>>>>>>>>>>>>>>  12   <<<<<<<<<<<<<<<<<<
ECHO =========================================================
ECHO.
ECHO Excel 12
ECHO.
ECHO =========================================================
IF "%EXC12%" == "" GOTO E_12_Skipped
%PTH_NET_2%\Vbc.exe  @bldrsp.txt     /reference:"%EXC12%" /define:EMPTY_STUB=False /libpath:%LIBPATHD% /out:%OUT12_DBG% /debug /define:DEBUG=1 
IF NOT %ERRORLEVEL% == 0 GOTO ErrorHandler

%PTH_NET_2%\Vbc.exe  @bldrsp.txt 	 /reference:"%EXC12%" /define:EMPTY_STUB=False /libpath:%LIBPATHR%  /out:%OUT12_REL% /optimize
IF NOT %ERRORLEVEL% == 0 GOTO ErrorHandler
GOTO E_12_OK

:E_12_Skipped
ECHO	Warning! EXC12 was not found; Excel 12 interface will not be available

:E_12_OK



ECHO.
ECHO.
ECHO =========================================================
ECHO.
ECHO All went well
ECHO.
ECHO =========================================================
EXIT /B 0


:ErrorHandler
ECHO Error compiling! %ERRORLEVEL% 
PAUSE
EXIT /B ERRORLEVEL






REM @ (Specify Response File)
REM Specifies a response file.
REM /debug
REM Produces debugging information.
REM /define
REM Defines symbols for conditional compilation.
REM /optimize
REM Enables/disables code optimization.
REM /nologo
REM Suppresses compiler banner information.
REM /optionstrict
REM Enforces strict language semantics.
REM /optionexplicit
REM Enforces explicit declaration of variables.
REM /target
REM Specifies the format of the output file.
REM /out
REM Specifies an output file.
REM /verbose
REM Outputs extra information during compilation.
REM /reference
REM Imports metadata from an assembly.
REM /rootnamespace
REM Specifies a namespace for all type declarations.




REM /addmodule
REM Causes the compiler to make all type information from the specified file(s) available to the project you are currently compiling.
REM /baseaddress
REM Specifies the base address of a DLL.
REM /codepage
REM Specifies the code page to use for all source code files in the compilation.
REM /delaysign
REM Specifies whether the assembly will be fully or partially signed.
REM /doc
REM Processes documentation comments to an XML file.
REM /filealign
REM Specifies where to align the sections of the output file.
REM /imports
REM Imports a namespace from a specified assembly.
REM /keycontainer
REM Specifies a key container name for a key pair to give an assembly a strong name.
REM /keyfile
REM Specifies a file that contains a key or key pair to give an assembly a strong name.
REM /langversion
REM Specifies that the compiler should accept only syntax that is included in the specified version of Visual Basic.
REM /libpath
REM Specifies the location of assemblies referenced by the /reference option.
REM /linkresource
REM Creates a link to a managed resource.
REM /main
REM Specifies the class that contains the Sub Main procedure to use at startup.
REM /moduleassemblyname
REM Specifies the name of the assembly that a module will be a part of.
REM /netcf
REM Sets the compiler to target the .NET Compact Framework.
REM /noconfig
REM Do not compile with Vbc.rsp.
REM /nostdlib
REM Causes the compiler not to reference the standard libraries.
REM /nowarn
REM Suppresses the compiler's ability to generate warnings.
REM /nowin32manifest
REM Instructs the compiler not to embed any application manifest into the executable file.
REM /optioncompare
REM Specifies whether string comparisons should be binary or use locale-specific text semantics.
REM /optioninfer
REM Enables the use of local type inference in variable declarations.
REM /platform
REM Specifies the processor platform the compiler targets for the output file.
REM /quiet
REM Prevents the compiler from displaying code for syntax-related errors and warnings.
REM /recurse
REM Searches subdirectories for source files to compile.
REM /removeintchecks
REM Disables integer overflow checking.
REM /sdkpath
REM Specifies the location of Mscorlib.dll and Microsoft.VisualBasic.dll.
REM /utf8output
REM Displays compiler output using UTF-8 encoding.
REM /vbruntime
REM Specifies that the compiler should compile without a reference to the Visual Basic Runtime Library, or with a reference to a specific runtime library.
REM /warnaserror
REM Promotes warnings to errors.
REM /win32icon
REM Inserts an .ico file into the output file.
REM /win32manifest
REM Identifies a user-defined Win32 application manifest file to be embedded into a project's portable executable (PE) file.
REM /win32resource
REM Inserts a Win32 resource into the output file.

@ECHO ON
